/*
 * @Description: regexp
 * @Author: rendc
 * @Date: 2022-09-29 10:23:22
 * @LastEditors: rendc
 * @LastEditTime: 2022-09-29 14:13:26
 */

// 正则表达式 修饰符
// var pattern = new RegExp("abc", "ig")
var pattern = /abc/ig

// var result = pattern.test("1a1bC2");
// console.log('🤡 CC - result', result);

var result = pattern.exec("123abc111abc");
// console.log('🤡 CC - pattern', pattern);
// console.log('🤡 CC - pattern.lastIndex', pattern.lastIndex);
// console.log('🤡 CC - result', result);

const regex1 = RegExp('foo*', 'g');
const str1 = 'table football, foosball';
let array1;

while ((array1 = regex1.exec(str1)) !== null) {
  console.log('🤡 CC - regex1', regex1.lastIndex);
  console.log('🤡 CC - array1', array1);
  console.log(`找到了 ${array1[0]}。 下次开始的索引位置 ${regex1.lastIndex}。`);
  console.log("找到了 " + array1[0] + "。 下次开始的索引位置 " + regex1.lastIndex + "。");
  console.log(`找到了${array1[0]}。任意内容${array1[0]}`);
}

// var pattern = /[A-Za-z0-9_]/ig
var pattern = /[^0-9_]/i
// console.log('🤡 CC - pattern', pattern.lastIndex);
// console.log('🤡 CC - result', pattern.test("0"));
// console.log('🤡 CC - pattern', pattern.lastIndex);
// console.log('🤡 CC - result', pattern.test("_"));
// console.log('🤡 CC - pattern', pattern.lastIndex);

// var pattern = /^abc[^0-9_]/i
// console.log('🤡 CC - result', pattern.test("123abca"));
// console.log('🤡 CC - result', pattern.test("abca"));
// var pattern = /^abc[^0-9_]$/i
// console.log('🤡 CC - result', pattern.test("abca"));
// console.log('🤡 CC - result', pattern.test("abcb"));
// console.log('🤡 CC - result', pattern.test("abca123"));

// var pattern = /^\w{4,5}$/i
// console.log('🤡 CC - result', pattern.test("a_a"));
// console.log('🤡 CC - result', pattern.test("ab_a"));
// console.log('🤡 CC - result', pattern.test("a9cb"));
// console.log('🤡 CC - result', pattern.test("a9cb2"));
// console.log('🤡 CC - result', pattern.test("abca123"));

// var pattern = /^[a-z]*/i
// console.log('🤡 CC - result', pattern.test("a"));
// console.log('🤡 CC - result', pattern.test("_a"));

var patternPhone = /^(13|15|16|17|18|19)\d{9}$/im
// console.log('🤡 CC - result', patternPhone.test("13"));
// console.log('🤡 CC - result', patternPhone.test("13912341234"));
console.log('🤡 CC - result', patternPhone.test("18891234134"));
// console.log('🤡 CC - result', patternPhone.test("14912341234"));
// console.log('🤡 CC - result', patternPhone.test("149123412341"));
// console.log('🤡 CC - result', patternPhone.test("1391234123"));

// 正则表达质验证用户邮箱
// 验证手机号
// 验证电话号
// 验证身份证号
// 验证url
